﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Content.Web;
using System.Collections.Generic;
using System.Linq;

namespace Content
{
    public partial class DbUnitDetailsLeft : DbUnit
	{
		public DbUnitDetailsLeft(string error, string description) : base(error, description)
		{
			InitializeComponent();
		}

        public DbUnitDetailsLeft(Unit unit) : base(unit)
        {
            InitializeComponent();
        }

        protected override Storyboard Storyboard
        {
            get 
            {
                return this.storyboard;
            }
        }

        protected override ObjectAnimationUsingKeyFrames DetailsTextAnimation
        {
            get 
            {
                return this.DetailsTextFrames;
            }
        }

        protected override DoubleAnimationUsingKeyFrames DetailsOpacityAnimation
        {
            get 
            {
                return this.DetailsOpacityFrames;
            }
        }

        protected override Grid GridLayout
        {
            get
            {
                return this.LayoutRoot;
            }
        }

        protected override int BulletsColumn
        {
            get 
            {
                return 0;
            }
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (error != null)
            {
                this.Title.Text = error;
                this.Description.Text = errorDescription;

                this.Title.Foreground = new SolidColorBrush(Colors.Red);
                this.Description.Foreground = new SolidColorBrush(Colors.Red);
            }
            else
            {
                var darkColors = this.GetDarkColors().AsQueryable();
                var foreground = darkColors.GetRandom();
                var brush = new SolidColorBrush(foreground);

                this.Title.Text = unit.UnitText;
                this.Title.Foreground = brush;

                this.Description.Text = unit.Description;
                this.Description.Foreground = brush;

                LoadBullets(foreground);

                this.storyboard.Begin();
            }
        }
    }
}